import type { Gears } from '@/composables/consoleButtons'
import { request } from '@/utils'

export function patrolingCruise(data: any) {
  return request({
    url: '/robot-remote-control/v2/upperControl',
    method: 'post',
    data: data
  })
}

export function patrolingVoice(params: any) {
  return request({
    url: '/robot-remote-control/v1/voiceControl',
    method: 'get',
    params
  })
}

//远程操控
export function patrolingRemote(code: string | number, data: any) {
  return request({
    url: `/robot-cruise/PatrolingControl/${code}`,
    method: 'post',
    data: data
  })
}

//切换模式
export function patrolingSetMode(code: string | number, mode: number) {
  return request({
    url: `/robot-cruise/PatrolingSetMode/${code}/${mode}`,
    method: 'post'
  })
}

//调用指定音频
export function playAudioById(audioId: number) {
  return request({
    url: `/robot-remote-control/playAudio/${audioId}`,
    method: 'get'
  })
}

//警告灯控制
export function controlAlarmLight(data: any) {
  return request({
    url: '/robot-remote-control/v1/VoiceAlarmLightControl',
    method: 'post',
    data: data
  })
}

export function postCalibrate(data: { code: string; waitingTime: number }) {
  return request({
    url: '/robot-remote-control/correction-ptz/v2',
    method: 'post',
    data
  })
}

/**
 * 获取自动跟踪状态
 * @param code 机器人编号
 */
export function getTrackingState(code: string | number): Promise<{ data: 0 | 1 }> {
  return request({
    url: `/robot-vehicle-log/v1/trackState/${code}`,
    method: 'get'
  })
}

/**
 * 修改自动跟踪状态
 * @param code 机器人编号
 * @param status 开关状态
 */
export function postTrackingState(code: string | number, status: 0 | 1 | -1) {
  return request({
    url: `/robot-remote-control/patrolling-auto-tracking/v1/${code}/${status}`,
    method: 'post'
  })
}

//获取围界车音频播放列表
export function getMusicList(robotCode: string | number) {
  return request({
    url: `/vehicle/point-task/v1/getTopMusicList/${robotCode}`,
    method: 'get'
  })
}

//一键获取云台角度
export function getPTZAngle(robotCode: string | number) {
  return request({
    url: `/robot-vehicle-log/v1/getPTZAngle/${robotCode}`,
    method: 'get'
  })
}

/**
 * 换档
 */
export function changeGear(data: {
  /**
   * 机器人编号
   */
  code: string | number
  /**
   * 档位
   */
  gear: Gears
}) {
  return request({
    url: '/robot-cruise/PatrolingGearControl/v1',
    method: 'post',
    data
  })
}
